********* Table A13 *********
clear all
set more off 
capture log close
 
* main path to data
global path "~/Dropbox/Paraguay/1_data/7_replication_dataverse"
capture cd "$path"	

*tables = analysis tables
global tables "$path/tables"

* Load and prepare data
use "$path/data/anr.dta", clear
xtset district_code periods



forval i = 1/9 {
    generate p`i' = (periods == `i')
}

// Generate the 'alt_p' variable and set it to 0
generate alt_p = 0


set more off
eststo clear


reghdfe l_anr ///
    i.p1##c.degree_z ///
    p2##c.degree_z ///
    p3##c.degree_z ///
    p4##c.degree_z ///
    p5##c.degree_z ///
    p6##c.degree_z ///
    alt_p ///
    p8##c.degree_z ///
    p9##c.degree_z ///
    , absorb(periods district_code periods#depa) cluster(district_code) nocons
	

eststo

capture cd "$tables"
esttab est* using "tableA13.tex", replace nonumber label style(tex) ///
		cells(b(star fmt(%12.4fc)) se(par fmt(%12.4fc))) ///
		stats( N r2 , fmt( %12.0fc %12.4fc ) ///
			label("\hline Observations"  ///
			  "\$R^2\$" )) ///
		keep( 1.p1#c.degree_z 1.p2#c.degree_z 1.p3#c.degree_z 1.p4#c.degree_z 1.p5#c.degree_z ///
     1.p6#c.degree_z  1.p8#c.degree_z 1.p9#c.degree_z ) ///	
		order(1.p1#c.degree_z 1.p2#c.degree_z 1.p3#c.degree_z 1.p4#c.degree_z 1.p5#c.degree_z ///
     1.p6#c.degree_z  1.p8#c.degree_z 1.p9#c.degree_z ) ///
		varlabels(1.p1#c.degree_z "1959-1963 \$\times\$ Avg. Degree" 1.p2#c.degree_z "1964-1968 \$\times\$ Avg. Degree" ///
		1.p3#c.degree_z "1969-1973 \$\times\$ Avg. Degree" 1.p4#c.degree_z "1974-1978 \$\times\$ Avg. Degree" ///
		1.p5#c.degree_z "1979-1983 \$\times\$ Avg. Degree" ///
     1.p6#c.degree_z  "1984-1988 \$\times\$ Avg. Degree" 1.p8#c.degree_z "1994-1998 \$\times\$ Avg. Degree" ///
	 1.p9#c.degree_z "1999-2003 \$\times\$ Avg. Degree") ///	
		collabels(, none) eqlabels(, none) starlevels(* 0.1 ** 0.05 *** 0.01) ///
		prehead(\begin{tabular}{l*{@M}{c}} \hline ///
			&  \multicolumn{1}{c}{Colorado Party Affiliations (log)}   \\ ///
			& (1)    \\)  ///
		posthead(\hline ) mlabels(, none) ///
		prefoot( ) postfoot(\hline \end{tabular})
